import { useLocation } from "react-router-dom"
import { PATH } from "@shared/const/paths"

const REG_EXP = /(\/[^/\d)]+\w)/gm

export const useMatchLocation = () => {
    const location = useLocation()

    return Array.from(location.pathname.matchAll(REG_EXP), match => `${match[0]}`)
        .reverse()
        .find(o => Object.values(PATH).includes(o))
}